﻿/* mvcForum
 * Copyright (C) 2010-2011 Steen F. Tøttrup
 * http://mvcforum.org/
 */

using System;
using System.Configuration;

namespace mvcForum.Core.Configuration {

	/// <summary>
	/// This class represent the MVCForum configuration section.
	/// TODO: Move most of this to the DB based configuration!
	/// </summary>
	public class MVCForumSettings : ConfigurationSection {
		private static MVCForumSettings settings = ConfigurationManager.GetSection("MVCForumSettings") as MVCForumSettings;

		private MVCForumSettings() { }

		public static MVCForumSettings Settings {
			get {
				return settings;
			}
		}

		//[ConfigurationProperty("notifications", IsRequired = false)]
		//public NotificationsContainerElement Notifications {
		//    get {
		//        return (NotificationsContainerElement)this["notifications"];
		//    }
		//    set {
		//        this["notifications"] = value;
		//    }
		//}

		[ConfigurationProperty("asynchronousAntiSpam")]
		public Boolean AsynchronousAntiSpam {
			get { return (Boolean)this["asynchronousAntiSpam"]; }
			set { this["asynchronousAntiSpam"] = value; }
		}

		[ConfigurationProperty("showOldPostsOnReply", DefaultValue = true)]
		public Boolean ShowOldPostsOnReply {
			get { return (Boolean)this["showOldPostsOnReply"]; }
			set { this["showOldPostsOnReply"] = value; }
		}

		[ConfigurationProperty("showDeletedMessages", DefaultValue = true)]
		public Boolean ShowDeletedMessages {
			get { return (Boolean)this["showDeletedMessages"]; }
			set { this["showDeletedMessages"] = value; }
		}

		[ConfigurationProperty("postsOnReply", DefaultValue = 10)]
		public Int32 PostsOnReply {
			get { return (Int32)this["postsOnReply"]; }
			set { this["postsOnReply"] = value; }
		}

		[ConfigurationProperty("defaultCulture", IsRequired = true)]
		public String DefaultCulture {
			get { return (String)this["defaultCulture"]; }
			set { this["defaultCulture"] = value; }
		}

		[ConfigurationProperty("defaultTimezone", IsRequired = true)]
		public String DefaultTimezone {
			get { return (String)this["defaultTimezone"]; }
			set { this["defaultTimezone"] = value; }
		}

		[ConfigurationProperty("maxFileSize", DefaultValue = 2000000, IsRequired = false)]
		[IntegerValidator()]
		public Int32 MaxFileSize {
			get { return (Int32)this["maxFileSize"]; }
			set { this["maxFileSize"] = value; }
		}

		[ConfigurationProperty("maxAttachmentsSize", DefaultValue = 10000000, IsRequired = false)]
		[IntegerValidator()]
		public Int32 MaxAttachmentsSize {
			get { return (Int32)this["maxAttachmentsSize"]; }
			set { this["maxAttachmentsSize"] = value; }
		}

		[ConfigurationProperty("topicsPerPage", DefaultValue = 15, IsRequired = false)]
		[IntegerValidator(MinValue = 1, MaxValue = 100)]
		public Int32 TopicsPerPage {
			get { return (Int32)this["topicsPerPage"]; }
			set { this["topicsPerPage"] = value; }
		}

		[ConfigurationProperty("messagesPerPage", DefaultValue = 20, IsRequired = false)]
		[IntegerValidator(MinValue = 1, MaxValue = 100)]
		public Int32 MessagesPerPage {
			get { return (Int32)this["messagesPerPage"]; }
			set { this["messagesPerPage"] = value; }
		}

		[ConfigurationProperty("allowedExtensions", IsRequired = false, DefaultValue = "jpg;png;gif")]
		public String AllowedExtensions {
			get { return (String)this["allowedExtensions"]; }
			set { this["allowedExtensions"] = value; }
		}

		[ConfigurationProperty("siteURL", IsRequired = true)]
		public String SiteURL {
			get { return (String)this["siteURL"]; }
			set { this["siteURL"] = value; }
		}

		[ConfigurationProperty("robotEmailAddress", IsRequired = true)]
		public String RobotEmailAddress {
			get { return (String)this["robotEmailAddress"]; }
			set { this["robotEmailAddress"] = value; }
		}

		[ConfigurationProperty("robotName", IsRequired = true)]
		public String RobotName {
			get { return (String)this["robotName"]; }
			set { this["robotName"] = value; }
		}

		[ConfigurationProperty("theme", IsRequired = false)]
		public String Theme {
			get { return (String)this["theme"]; }
			set { this["theme"] = value; }
		}

		[ConfigurationProperty("allowUserDefinedTheme", DefaultValue = false, IsRequired = false)]
		public Boolean AllowUserDefinedTheme {
			get { return (Boolean)this["allowUserDefinedTheme"]; }
			set { this["allowUserDefinedTheme"] = value; }
		}
		//[ConfigurationProperty("dataAssembly", IsRequired = true)]
		//[StringValidator(InvalidCharacters = "  ~!@#$%^&*()[]{}/;’\"|\\", MinLength = 1, MaxLength = 256)]
		//public string DataAssembly {
		//    get { return (string)this["dataAssembly"]; }
		//    set { this["dataAssembly"] = value; }
		//}

		//[ConfigurationProperty("dataType", IsRequired = true)]
		//[StringValidator(InvalidCharacters = "  ~!@#$%^&*()[]{}/;’\"|\\", MinLength = 1, MaxLength = 256)]
		//public string DataType {
		//    get { return (string)this["dataType"]; }
		//    set { this["dataType"] = value; }
		//}
	}
}